package com.yoga.admin.api.web;

import com.yoga.admin.api.annotation.LoginUser;
import com.yoga.common.appexception.AppException;
import com.yoga.common.appexception.YogaResult;
import com.yoga.common.bo.YogaAdminBO;
import com.yoga.common.bo.YogaUserBO;
import com.yoga.common.page.PageBO;
import com.yoga.common.qto.YogaUserQTO;
import com.yoga.manager.admin.AdminYogaUserManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created by hdx on 2020/10/17.
 */
@RestController
@RequestMapping("${basePath}")
public class AdminYogaUserController {

    @Resource
    private AdminYogaUserManager yogaUserManager;

    @PostMapping("/yogaUser/update")
    public YogaResult<Boolean> updateData(@LoginUser YogaAdminBO adminBO, YogaUserBO yogaUserBO) throws AppException {
        Boolean result = yogaUserManager.updateData(yogaUserBO);

        return new YogaResult<>(result);
    }

    @GetMapping("/yogaUser/findById")
    public YogaResult<YogaUserBO> findYogaUserBOById(@LoginUser YogaAdminBO adminBO, Long yogaUserId) throws AppException {
        YogaUserBO result = yogaUserManager.findById(yogaUserId);

        return new YogaResult<>(result);
    }

    @PostMapping("/yogaUser/findForPage")
    public YogaResult<PageBO<YogaUserBO>> findForPage(@LoginUser YogaAdminBO adminBO, YogaUserQTO yogaUserQTO) throws AppException {
        PageBO<YogaUserBO> result = yogaUserManager.findForPage(yogaUserQTO);

        return new YogaResult<>();
    }

}
